home *** CD-ROM | disk | FTP | other *** search
- /* EasyAmiga.c By Kamran Karimi.
-
- This program tranfers files between an Amiga and
- a PC using a serial NULL modem cable. Another
- Program should run on the PC.
-
- To make EasyAmiga, Remote.c, Local.c and Serial.c are
- also needed.
-
- Compiled with SAS/C 6.50
- 1> sc EasyAmiga.c
- 1> slink lib:c.o EasyAmiga.o Remote.o Local.o Serial.o lib lib:sc.lib\
- lib:amiga.lib
-
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #include <exec/types.h>
- #include <exec/memory.h>
-
- #include <dos.h>
-
- #include <intuition/intuition.h>
- #include <clib/exec_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/graphics_protos.h>
-
- #include "EasyAmiga.h"
-
- struct FInfo {
- struct FInfo *next,*prev;
- byte Selected,type;
- char name[32];
- char data[MAXAMINFOLEN + 10];
- };
-
- extern struct PacketStruct Packet;
-
- #define SERTESTLEN 255
- #define PACKET_SIZE 255
- struct PacketStruct
- {
- UBYTE Len;
- UBYTE Data[PACKET_SIZE + 2];
- };
-
- extern LONG ReceivePacket(VOID),SendPacket(VOID),ConfigSerial(ULONG BAUD);
- extern LONG OpenSerial(VOID);
- extern VOID CloseSerial(VOID);
- extern VOID ClrSer(VOID);
-
- extern LONG GetSynch(VOID),PutSynch(VOID);
- extern LONG OpenTimer(VOID);
- extern VOID CloseTimer(VOID);
-
- extern LONG LocalDir(VOID);
- extern LONG LocalDel(VOID),LocalMKDir(char *Name),LocalCd(char *Path);
-
- extern LONG RemoteMKDir(char *Name),RemoteDel(VOID),RemoteCd(char *Path);
- extern LONG RemoteDir(VOID),RemoteReceive(VOID),RemoteSend(VOID);
- extern VOID RemoteQuit(VOID);
- extern LONG CheckLink(VOID);
-
- extern struct ExecBase *SysBase;
- struct IntuitionBase *IntuitionBase;
- struct GfxBase *GfxBase;
- extern struct DOSBase *DOSBase;
- struct Window *MainWin;
- struct Screen *MainScr;
-
- FILE *ConfigFile;
- char ConfigFileName[25] = {"S:EasyTransfer.Config"};
-
- long OverWriteProtect = TRUE;
-
- long NumDone;
- SHORT Active = -1;
- USHORT OldVPot[2],OldHPot[2],SelectPos,FileNum[2] = {0,0},HPos[2] = {0,0};
- struct FInfo *First[2] = { NULL, NULL };
- struct FInfo *ItemAddr[2][MAXFILENUM] =
- {
- { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
- { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
- };
-
- char OrigPath[250];
-
- size_t FileBuffSize = 32000;
-
- #define DEFUNIT 0
- #define DEFDELAY 3
- #define DEFCHECK 5
- #define DEFCHECKSUM 1
-
- ULONG NowSec,NowMic;
-
- char SerialName[SERNAMELEN];
- SHORT UnitNum;
- SHORT DelayTime;
- SHORT CheckTime;
- SHORT CheckSumTry;
- SHORT Method;
- SHORT MSpeed, CurrSpeed;
- SHORT Mode = BIN;
-
- ULONG Speed[MAXHARDSPEED] =
- { 300, 600,1200,2400,4800,9600,19200,38400,57600,115200 };
-
- SHORT Row = 0;
- LONG MessNum[MAXMESSAGE] = { -1, -1, -1, -1};
-
-
- VOID PrintFileName(char *Name)
- {
- if(Name)
- sprintf(TransFileName,"%-31.31s",Name);
- else
- sprintf(TransFileName,"%-31.31s"," ");
- PrintIText(MainWin->RPort, &TransFileText,0,0);
- }
-
- VOID ShowRemainder(ULONG Transfered, ULONG Total)
- {
- ULONG newTransfered;
- static ULONG prevTransfered = 0;
-
- if(Total == 0)
- {
- SetAPen(MainWin->RPort,0);
- RectFill(MainWin->RPort,371,159,627,167);
- prevTransfered = 0;
- }
- else
- {
- if(Transfered > Total) Transfered = Total;
- newTransfered = 256 * Transfered / Total;
- if((newTransfered > (prevTransfered + 5)) || (Transfered == Total))
- {
- SetAPen(MainWin->RPort,3);
- RectFill(MainWin->RPort,371,159,371 + newTransfered,167);
- prevTransfered = newTransfered;
- }
- }
- }
-
- VOID Message(LONG MessageNum)
- {
- LONG count;
- static int Alt[4] = {11,8,11,8};
-
- if(MessageNum == -1) return;
- if(MessageNum == CURR_SPEED)
- {
- for(count = 0; count < 6; count++)
- MessageT[MessageNum][count + 7] = SpeedTexts[CurrSpeed].IText[count];
- }
- if(MessageNum == SPEED_DONE)
- {
- for(count = 0; count < 6; count++)
- MessageT[MessageNum][count + 12] = SpeedTexts[CurrSpeed].IText[count];
- }
- if(Row < MAXMESSAGE)
- {
- if(Alt[Row] == 8) Alt[Row] = 11;
- else Alt[Row] = 8;
- if(Alt[Row] == 11)
- {
- strcpy(MessIntuiText[Row].IText," ");
- PrintIText(MainWin->RPort, &MessIntuiText[Row],8,0);
- }
- strcpy(MessIntuiText[Row].IText,MessageT[MessageNum]);
- PrintIText(MainWin->RPort, &MessIntuiText[Row],Alt[Row],0);
- MessNum[Row] = MessageNum;
- Row++;
- return;
- }
- for(count = 0; count < MAXMESSAGE - 1; count++)
- {
- if(MessNum[count + 1] != -1)
- {
- if(Alt[count] == 8) Alt[count] = 11;
- else Alt[count] = 8;
- if(Alt[count] == 11)
- {
- strcpy(MessIntuiText[count].IText," ");
- PrintIText(MainWin->RPort, &MessIntuiText[count],8,0);
- }
- strcpy(MessIntuiText[count].IText,MessIntuiText[count + 1].IText);
- PrintIText(MainWin->RPort, &MessIntuiText[count],Alt[count],0);
- MessNum[count] = MessNum[count + 1];
- }
- }
- if(Alt[MAXMESSAGE - 1] == 8) Alt[MAXMESSAGE - 1] = 11;
- else Alt[MAXMESSAGE - 1] = 8;
- if(Alt[MAXMESSAGE - 1] == 11)
- {
- strcpy(MessIntuiText[MAXMESSAGE - 1].IText," ");
- PrintIText(MainWin->RPort, &MessIntuiText[MAXMESSAGE - 1],8,0);
- }
- strcpy(MessIntuiText[MAXMESSAGE - 1].IText,MessageT[MessageNum]);
- PrintIText(MainWin->RPort,&MessIntuiText[MAXMESSAGE - 1],
- Alt[MAXMESSAGE - 1],0);
- MessNum[MAXMESSAGE - 1] = MessageNum;
- }
-
-
- VOID WaitPointer(VOID)
- {
- RemoveGList(MainWin,PCSelect,MAXFILENUM);
- RemoveGList(MainWin,AMSelect,MAXFILENUM);
- RemoveGList(MainWin,Gads,AMHPROP);
- SetPointer(MainWin, WaitPointerData, 16, 16, 0, 0);
- }
-
- VOID NormalPointer(VOID)
- {
- ClearPointer(MainWin);
- AddGList(MainWin,Gads,-1,AMHPROP,NULL);
- AddGList(MainWin,PCSelect,-1,MAXFILENUM,NULL);
- AddGList(MainWin,AMSelect,-1,MAXFILENUM,NULL);
- }
-
-
- LONG PutSpeedMethodDelay(VOID)
- {
- LONG Error,MinSpeed = MINSPEED - 1;
-
- if(ConfigSerial(Speed[MinSpeed])) return ERROR_SetSer;
- Packet.Len = 1;
- if(Method == BIOS)
- Packet.Data[0] = 'B';
- else
- Packet.Data[0] = 'H';
- if((Error = SendPacket())) return Error;
- if((Error = GetSynch())) return Error;
- Packet.Len = 1;
- Packet.Data[0] = CurrSpeed;
- if((Error = SendPacket())) return Error;
- if((Error = GetSynch())) return Error;
- Packet.Len = 1;
- Packet.Data[0] = DelayTime;
- if((Error = SendPacket())) return Error;
- if((Error = GetSynch())) return Error;
- Packet.Len = 1;
- Packet.Data[0] = CheckSumTry;
- if((Error = SendPacket())) return Error;
- if((Error = GetSynch())) return Error;
- else return NO_ERROR;
- }
-
-
- LONG SetSerial(VOID)
- {
- LONG Error,done = FALSE;
- UBYTE count;
-
- do
- {
- Message(CURR_SPEED);
- ClrSer();
- Delay(150);
- if(ConfigSerial(Speed[CurrSpeed])) return ERROR_SetSer;
- if((Error = PutSynch())) return Error;
- if((Error = GetSynch())) return Error;
- Packet.Len = SERTESTLEN;
- for(count = 0; count < SERTESTLEN; count++)
- Packet.Data[count] = count;
- if((Error = SendPacket())) return Error;
- Packet.Len = 1;
- if((Error = ReceivePacket())) return Error;
- if(Packet.Data[0] == '!')
- {
- Message(SERVER_AGREED);
- if((Error = PutSynch())) return Error;
- Packet.Len = SERTESTLEN;
- Error = ReceivePacket();
- for(count = 0; count < SERTESTLEN; count++)
- if(Packet.Data[count] != (UBYTE)(SERTESTLEN - count - 1)) break;
- if((Error == ERROR_Timeout) || (count < SERTESTLEN))
- {
- Message(I_DONT_AGREE);
- Packet.Len = 1;
- Packet.Data[0] = '1';
- if((Error = SendPacket())) return Error;
- CurrSpeed--;
- }
- else
- {
- Message(I_AGREED);
- Packet.Len = 1;
- Packet.Data[0] = '!';
- if((Error = SendPacket())) return Error;
- Message(SPEED_DONE);
- done = TRUE;
- }
- }
- else
- {
- Message(SERVER_DONT_AGREE);
- if((Error = PutSynch())) return Error;
- CurrSpeed--;
- }
- if((Error = GetSynch())) return Error;
- }while((!done) && (CurrSpeed >= 0));
- if(CurrSpeed < 0) return ERROR_NoSpeed;
- return NO_ERROR;
- }
-
-
- VOID FMode(VOID)
- {
- if(Mode == TEXT) Mode = BIN;
- else Mode = TEXT;
- Gads[TEXTBIN - 1].GadgetText = &Texts[6 + Mode];
- RefreshGList(&Gads[TEXTBIN - 1],MainWin,NULL,1);
- }
-
- VOID Activate(LONG Cause)
- {
- if(Cause == AM)
- {
- if(Active != AM)
- {
- Borders[41].FrontPen = 1;
- Borders[40].FrontPen = 2;
- Borders[39].FrontPen = 2;
- Borders[38].FrontPen = 1;
- Borders[38].NextBorder = NULL;
- DrawBorder(MainWin->RPort,&Borders[41],0,0);
- Borders[38].NextBorder = &Borders[37];
- if(Gads[0].GadgetText != &Texts[0])
- {
- Gads[0].GadgetText = &Texts[1];
- RefreshGList(&Gads[0],MainWin,NULL,1);
- }
- Active = AM;
- }
- }
- else if(Cause == PC)
- {
- if(Active != PC)
- {
- Borders[41].FrontPen = 2;
- Borders[40].FrontPen = 1;
- Borders[39].FrontPen = 1;
- Borders[38].FrontPen = 2;
- Borders[38].NextBorder = NULL;
- DrawBorder(MainWin->RPort,&Borders[41],0,0);
- Borders[38].NextBorder = &Borders[37];
- if(Gads[0].GadgetText != &Texts[0])
- {
- Gads[0].GadgetText = &Texts[2];
- RefreshGList(&Gads[0],MainWin,NULL,1);
- }
- Active = PC;
- }
- }
- }
-
-
-
- VOID Configure(VOID)
- {
- LONG count, Done = FALSE;
- LONG Err = FALSE;
- USHORT GadgetNum;
- struct Gadget *GadgetPtr;
- struct IntuiMessage *message;
- struct Window *ConfigWin;
- SHORT tempMethod = Method,tempSpeed = MSpeed,t1,t2;
-
- if(Gads[0].GadgetText != &Texts[0]) /* start */ { FMode(); return; }
-
- sprintf(UnitBuff,"%d",UnitNum % 100);
- UnitInfo.LongInt = UnitNum;
- sprintf(DelayBuff,"%d",DelayTime % 100);
- DelayInfo.LongInt = DelayTime;
- sprintf(CheckBuff,"%d",CheckTime % 100);
- CheckInfo.LongInt = CheckTime;
- sprintf(CheckSumBuff,"%d",CheckSumTry % 100);
- CheckSumInfo.LongInt = CheckSumTry;
- strcpy(SerNameBuff,SerialName);
- if(tempMethod == BIOS)
- ConfigGads[2].GadgetText = &ConfigTexts[3];
- else
- ConfigGads[2].GadgetText = &ConfigTexts[4];
- ConfigWindow.Screen = MainScr;
- if(!(ConfigWin = (struct Window *) OpenWindow(&ConfigWindow))) return;
- DrawBorder(ConfigWin->RPort,&ConfigBorders[11],330,84);
- PrintIText(ConfigWin->RPort,&ConfigTexts[14],0,0);
- PrintIText(ConfigWin->RPort,&SpeedTexts[tempSpeed - 1],332,84);
- t1 = LeftArrow.PlanePick;
- t2 = RightArrow.LeftEdge;
- RightArrow.LeftEdge = 118;
- LeftArrow.PlanePick = RightArrow.PlanePick = 1;
- DrawImage(ConfigWin->RPort,&RightArrow,310,1);
- LeftArrow.PlanePick = RightArrow.PlanePick = t1;
- RightArrow.LeftEdge = t2;
- do
- {
- WaitPort(ConfigWin->UserPort);
- while(message = (struct IntuiMessage *)GetMsg(ConfigWin->UserPort))
- {
- GadgetPtr = (struct Gadget *)message->IAddress;
- GadgetNum = GadgetPtr->GadgetID;
- ReplyMsg((struct Message *) message);
- switch (GadgetNum)
- {
- case SPEEDL: if(tempSpeed > MINSPEED) tempSpeed--;
- PrintIText(ConfigWin->RPort,&SpeedTexts[tempSpeed -1],332,84);
- break;
-
- case SPEEDR: if(tempSpeed < MaxSpeed[tempMethod]) tempSpeed++;
- PrintIText(ConfigWin->RPort,&SpeedTexts[tempSpeed -1],332,84);
- break;
-
- case USEBIOS:
- if(tempMethod == BIOS)
- {
- tempMethod = HARD;
- ConfigGads[2].GadgetText = &ConfigTexts[4];
- }
- else
- {
- tempMethod = BIOS;
- ConfigGads[2].GadgetText = &ConfigTexts[3];
- if(tempSpeed > MaxSpeed[tempMethod])
- {
- tempSpeed = MaxSpeed[tempMethod];
- PrintIText(ConfigWin->RPort,&SpeedTexts[tempSpeed-1],332,84);
- }
- }
- RefreshGList(&ConfigGads[2],ConfigWin,NULL,1);
- break;
- case OK:
- if(SerNameBuff[0] != NULL)
- strcpy(SerialName,SerNameBuff);
- else
- strcpy(SerialName,"serial.device");
-
- if((UnitBuff[0] != NULL) && (UnitInfo.LongInt >= 0))
- UnitNum = UnitInfo.LongInt;
- else UnitNum = DEFUNIT;
-
- if((DelayBuff[0] != NULL) && (DelayInfo.LongInt > 0))
- DelayTime = DelayInfo.LongInt;
- else DelayTime = DEFDELAY;
-
- if((CheckBuff[0] != NULL) && (CheckInfo.LongInt >= 0))
- CheckTime = CheckInfo.LongInt;
- else CheckTime = DEFCHECK;
-
- if((CheckSumBuff[0] != NULL) && (CheckSumInfo.LongInt >= 0))
- CheckSumTry = CheckSumInfo.LongInt;
- else CheckSumTry = DEFCHECKSUM;
-
- Method = tempMethod;
- MSpeed = tempSpeed;
- Done = TRUE;
-
- break;
- case SAVE: Err = FALSE;
- ConfigFile = fopen(ConfigFileName,"w");
- if(ConfigFile)
- {
- if(SerNameBuff[0] != NULL)
- { if(!fprintf(ConfigFile,"%s\n",SerNameBuff)) Err = TRUE; }
- else
- if(!fprintf(ConfigFile,"%s\n",SerialName)) Err = TRUE;
-
- if(UnitInfo.LongInt >= 0)
- {if(!fprintf(ConfigFile,"%d\n",UnitInfo.LongInt)) Err = TRUE;}
- else
- if(!fprintf(ConfigFile,"%d\n",UnitNum)) Err = TRUE;
-
- if(DelayInfo.LongInt > 0)
- {if(!fprintf(ConfigFile,"%d\n",DelayInfo.LongInt)) Err = TRUE;}
- else
- if(!fprintf(ConfigFile,"%d\n",DelayTime)) Err = TRUE;
-
- if(CheckInfo.LongInt >= 0)
- {if(!fprintf(ConfigFile,"%d\n",CheckInfo.LongInt)) Err = TRUE;}
- else
- if(!fprintf(ConfigFile,"%d\n",CheckTime)) Err = TRUE;
-
- if(CheckSumInfo.LongInt >= 0)
- {if(!fprintf(ConfigFile,"%d\n",CheckSumInfo.LongInt)) Err = TRUE;}
- else
- if(!fprintf(ConfigFile,"%d\n",CheckSumTry)) Err = TRUE;
-
- if(!fprintf(ConfigFile,"%d\n",tempSpeed)) Err = TRUE;
- if(!fprintf(ConfigFile,"%d\n",tempMethod)) Err = TRUE;
- fclose(ConfigFile);
- }
- else Err = TRUE;
- break;
-
- case CANCEL:
- strcpy(SerNameBuff,SerialName);
- UnitInfo.LongInt = UnitNum;
- DelayInfo.LongInt = DelayTime;
- CheckInfo.LongInt = CheckTime;
- CheckSumInfo.LongInt = CheckSumTry;
- Done = TRUE;
- break;
-
- case SERNAME: if(SerNameBuff[0] != NULL)
- strcpy(SerialName,SerNameBuff);
- else
- {
- strcpy(SerialName,"serial.device");
- strcpy(SerNameBuff,"serial.device");
- }
- RefreshGList(&ConfigGads[6],ConfigWin,NULL,1);
- break;
-
- case UNIT: if(UnitInfo.LongInt >= 0)
- UnitNum = UnitInfo.LongInt;
- else UnitInfo.LongInt = UnitNum = DEFUNIT;
- sprintf(UnitBuff,"%d",UnitNum);
- RefreshGList(&ConfigGads[7],ConfigWin,NULL,1);
- break;
-
- case DELAY: if(DelayInfo.LongInt > 0)
- DelayTime = DelayInfo.LongInt;
- else DelayInfo.LongInt = DelayTime = DEFDELAY;
- sprintf(DelayBuff,"%d",DelayTime);
- RefreshGList(&ConfigGads[8],ConfigWin,NULL,1);
- break;
-
- case CHECK: if(CheckInfo.LongInt >= 0)
- CheckTime = CheckInfo.LongInt;
- else CheckInfo.LongInt = CheckTime = DEFCHECK;
- sprintf(CheckBuff,"%d",CheckTime);
- RefreshGList(&ConfigGads[9],ConfigWin,NULL,1);
- break;
-
- case CHECKSUM: if(CheckSumInfo.LongInt >= 0)
- CheckSumTry = CheckSumInfo.LongInt;
- else CheckSumInfo.LongInt = CheckSumTry = DEFCHECKSUM;
- sprintf(CheckSumBuff,"%d",CheckSumTry);
- RefreshGList(&ConfigGads[10],ConfigWin,NULL,1);
- break;
- default: break;
- }
- }
- }while(!Done);
- if(ConfigWin) CloseWindow(ConfigWin);
- DrawImage(MainWin->RPort,&DownArrow,297,5);
- DrawImage(MainWin->RPort,&DownArrow,328,5);
- DrawImage(MainWin->RPort,&RightArrow,5,23);
- DrawImage(MainWin->RPort,&RightArrow,354,23);
- DrawBorder(MainWin->RPort,(struct Border *) &Borders[41],0,0);
- PrintIText(MainWin->RPort,&Texts[12],110,120);
- PrintIText(MainWin->RPort,&Texts[13],430,120);
- DrawImage(MainWin->RPort,&NameImage, 20,185);
- for(count = 0; count < 4; count++)
- {
- if(MessNum[count] != -1)
- {
- strcpy(MessIntuiText[count].IText,MessageT[MessNum[count]]);
- PrintIText(MainWin->RPort, &MessIntuiText[count],8,0);
- }
- }
- if(Err) Message(ERROR_WriteConfig);
- }
-
-
- VOID FreeFInfo(LONG Cause)
- {
- struct FInfo *next;
-
- while(First[Cause])
- {
- next = First[Cause]->next;
- free(First[Cause]);
- First[Cause] = next;
- }
- FileNum[Cause] = 0;
- PGHInfo[Cause].HorizBody = MAXBODY;
- PGVInfo[Cause].VertBody = MAXBODY;
- NewModifyProp(&Gads[PCVPROP + Cause - 1],MainWin,NULL,PGVInfo[Cause].Flags,
- PGVInfo[Cause].HorizPot,PGVInfo[Cause].VertPot,
- PGVInfo[Cause].HorizBody,PGVInfo[Cause].VertBody,1);
-
- NewModifyProp(&Gads[PCHPROP + Cause - 1],MainWin,NULL,PGHInfo[Cause].Flags,
- PGHInfo[Cause].HorizPot,PGHInfo[Cause].VertPot,
- PGHInfo[Cause].HorizBody,PGHInfo[Cause].VertBody,1);
- }
-
-
- VOID ClearDir(LONG Cause)
- {
- struct Gadget *Selected;
- long count;
-
- Selected = (Cause == AM) ? AMSelect : PCSelect;
- FreeFInfo(Cause);
- RemoveGList(MainWin,Selected,MAXFILENUM);
- for(count = 0;count < MAXFILENUM;count++)
- {
- strncpy(String[Cause][count],
- " ", MAXDISPLAY);
- String[Cause][count][MAXDISPLAY] = NULL;
- }
- AddGList(MainWin,Selected,-1,MAXFILENUM,NULL);
- RefreshGList(Selected,MainWin,NULL,MAXFILENUM);
- }
-
- VOID HandleCd(LONG Cause);
-
- VOID EntrySelect(LONG Cause, LONG GadNum)
- {
- struct Gadget *Selected;
- static ULONG PrevSec = 0,PrevMic = 0;
- static long SelGad = -1;
- char *Buff,Sep;
- long buffLen;
-
- Selected = (Cause == PC) ? PCSelect : AMSelect;
- Activate(Cause);
- if((GadNum + 1) > FileNum[Cause])
- {
- if(Selected[GadNum].Flags & SELECTED) Selected[GadNum].Flags &= ~SELECTED;
- strncpy(String[Cause][GadNum],
- " ", MAXDISPLAY);
- String[Cause][GadNum][MAXDISPLAY] = NULL;
- RefreshGList(&Selected[GadNum],MainWin,NULL,1);
- return;
- }
- RemoveGList(MainWin,Selected,MAXFILENUM);
- if(Selected[GadNum].Flags & SELECTED)
- {
- if(ItemAddr[Cause][GadNum]->type == FILETYPE)
- SelTexts[Cause][GadNum].FrontPen = DPEN;
- else
- SelTexts[Cause][GadNum].FrontPen = FPEN;
- ItemAddr[Cause][GadNum]->Selected = TRUE;
- }
- else
- {
- if(ItemAddr[Cause][GadNum]->type == FILETYPE)
- SelTexts[Cause][GadNum].FrontPen = FPEN;
- else
- SelTexts[Cause][GadNum].FrontPen = DPEN;
- ItemAddr[Cause][GadNum]->Selected = FALSE;
- }
- AddGList(MainWin,Selected,-1,MAXFILENUM,NULL);
- RefreshGList(Selected,MainWin,NULL,MAXFILENUM);
-
- if(ItemAddr[Cause][GadNum]->type == DIRTYPE)
- {
- if( (GadNum == SelGad) && DoubleClick(PrevSec,PrevMic,NowSec,NowMic))
- {
- Buff = (Cause == PC) ? PCBuff : AMBuff;
- if(strlen(ItemAddr[Cause][GadNum]->name) + strlen(Buff) < BUFFLEN - 1)
- {
- Sep = (Cause == PC) ? '\\' : '/';
- buffLen = strlen(Buff);
- if(Buff[buffLen - 1] != Sep)
- {
- if(!((Cause == AM) && (Buff[buffLen - 1] == ':')))
- {
- Buff[buffLen] = Sep;
- Buff[buffLen + 1] = NULL;
- }
- }
- strcat(Buff,ItemAddr[Cause][GadNum]->name);
- HandleCd(Cause);
- }
- }
- PrevSec = NowSec;
- PrevMic = NowMic;
- SelGad = GadNum;
- }
- }
-
-
- VOID ModifyP(LONG Pos, LONG Cause)
- {
- LONG vbody;
- USHORT vb;
-
- if (FileNum[Cause] <= MAXFILENUM) vbody = MAXBODY;
- else vbody = (MAXBODY * MAXFILENUM) / FileNum[Cause];
- vb = (USHORT)vbody;
- NewModifyProp(&Gads[PCVPROP + Cause - 1],MainWin,NULL,PGVInfo[Cause].Flags,
- PGVInfo[Cause].HorizPot,Pos,PGVInfo[Cause].HorizBody,vb,1);
- OldVPot[Cause] = Pos;
-
- NewModifyProp(&Gads[PCHPROP + Cause - 1],MainWin,NULL,PGHInfo[Cause].Flags,
- PGHInfo[Cause].HorizPot,PGHInfo[Cause].VertPot,
- MAXBODY / 2,PGHInfo[Cause].VertBody,1);
- }
-
-
- VOID HandleDir(VOID)
- {
- LONG Error;
- struct FInfo *tmp;
- short count,ActualNum;
- struct Gadget *Selected;
- long Cause;
-
- if(Active == PC)
- {
- Selected = PCSelect;
- Cause = PC;
- }
- else
- {
- Selected = AMSelect;
- Cause = AM;
- }
- RemoveGList(MainWin,Selected,MAXFILENUM);
- for(count = 0; count < MAXFILENUM; count++)
- Selected[count].Flags &= ~SELECTED;
- AddGList(MainWin,Selected,-1,MAXFILENUM,NULL);
- RefreshGList(Selected,MainWin,NULL,MAXFILENUM);
- if(First[Cause]) ClearDir(Cause);
-
- WaitPointer();
- if(Cause == AM)
- {
- if((Error = LocalDir())) Message(Error);
- else Message(SUCCESS);
- }
- else
- {
- if((Error = RemoteDir())) Message(Error);
- else Message(SUCCESS);
- }
- ActualNum = min(MAXFILENUM,FileNum[Cause]);
- NormalPointer();
-
- if(ActualNum > 0)
- {
- RemoveGList(MainWin,Selected,MAXFILENUM);
- for(tmp = First[Cause],count = 0; count < ActualNum; tmp = tmp->next,count++)
- {
- ItemAddr[Cause][count] = tmp;
- if(tmp->type == FILETYPE)
- SelTexts[Cause][count].FrontPen = FPEN;
- else
- SelTexts[Cause][count].FrontPen = DPEN;
- strncpy(String[Cause][count],&(tmp->data[HPos[Cause]]), MAXDISPLAY);
- String[Cause][count][MAXDISPLAY] = NULL;
- }
- AddGList(MainWin,Selected,-1,MAXFILENUM,NULL);
- RefreshGList(Selected,MainWin,NULL,MAXFILENUM);
- ModifyP(0,Cause);
- }
- }
-
-
- VOID CloseAll(LONG RetCode)
- {
- if(UpData) FreeMem(UpData,sizeof(Up));
- if(DownData) FreeMem(DownData,sizeof(Down));
- if(LeftData) FreeMem(LeftData,sizeof(Left));
- if(RightData) FreeMem(RightData,sizeof(Right));
- if(MainWin) CloseWindow(MainWin);
- if(MainScr) CloseScreen(MainScr);
- // if(DOSBase) CloseLibrary((struct Library *)DOSBase);
- if(GfxBase) CloseLibrary((struct Library *)GfxBase);
- if(IntuitionBase) CloseLibrary((struct Library *)IntuitionBase);
- if(OrigPath[0]) chdir(OrigPath);
- CloseSerial();
- exit(RetCode);
- }
-
-
- VOID OpenAll(VOID)
- {
- LONG Err;
- char ConfigBuffer[101];
-
- if(!(IntuitionBase = (struct IntuitionBase *)
- OpenLibrary("intuition.library",0L))) CloseAll(20L);
-
- if (!(GfxBase = (struct GfxBase *)
- OpenLibrary("graphics.library",0L))) CloseAll(20L);
-
- // if (!(DOSBase = (struct DOSBase *)
- // OpenLibrary("dos.library",0L))) CloseAll(20L);
- if(!(MainScr = (struct Screen *) OpenScreen(&MyScreen))) CloseAll(10L);
- LoadRGB4(&(MainScr->ViewPort),ColourTable,4);
-
- MyWindow.Screen = MainScr;
- if(!(MainWin = (struct Window *) OpenWindow(&MyWindow))) CloseAll(10L);
-
- UpData = (USHORT *) AllocMem(sizeof(Up),MEMF_CHIP);
- DownData = (USHORT *) AllocMem(sizeof(Down),MEMF_CHIP);
- LeftData = (USHORT *) AllocMem(sizeof(Left),MEMF_CHIP);
- RightData = (USHORT *) AllocMem(sizeof(Right),MEMF_CHIP);
- CopyMem(Up,UpData,sizeof(Up));
- CopyMem(Down,DownData,sizeof(Down));
- CopyMem(Left,LeftData,sizeof(Left));
- CopyMem(Right,RightData,sizeof(Right));
- UpArrow.ImageData = UpData;
- DownArrow.ImageData = DownData;
- LeftArrow.ImageData = LeftData;
- RightArrow.ImageData = RightData;
- DrawImage(MainWin->RPort,&DownArrow,297,5);
- DrawImage(MainWin->RPort,&DownArrow,328,5);
- DrawImage(MainWin->RPort,&RightArrow,5,23);
- DrawImage(MainWin->RPort,&RightArrow,354,23);
- DrawBorder(MainWin->RPort,&Borders[41],0,0);
- PrintIText(MainWin->RPort,&Texts[12],110,120);
- PrintIText(MainWin->RPort,&Texts[13],430,120);
- DrawImage(MainWin->RPort,&NameImage, 20,185);
- SelectPos = AddGList(MainWin,AMSelect,-1,MAXFILENUM,NULL);
- SelectPos = AddGList(MainWin,PCSelect,-1,MAXFILENUM,NULL);
- if(getcd(0,OrigPath) == -1) OrigPath[0] = NULL;
- else
- {
- strcpy(AMBuff,OrigPath);
- RefreshGList(&Gads[AMPATH - 1],MainWin,NULL,1);
- }
- Activate(AM);
- Err = FALSE;
- ConfigFile = fopen(ConfigFileName,"r");
- if(ConfigFile)
- {
- fgets(ConfigBuffer, 101, ConfigFile);
- if(ConfigBuffer[0] == NULL) Err = TRUE;
- if(ConfigBuffer[strlen(ConfigBuffer) - 1] == '\n')
- ConfigBuffer[strlen(ConfigBuffer) - 1] = NULL;
- strcpy(SerialName,ConfigBuffer);
-
- fgets(ConfigBuffer, 101, ConfigFile);
- UnitNum = atoi(ConfigBuffer);
- if((UnitNum < 0) || (UnitNum > 99)) Err = TRUE;
-
- fgets(ConfigBuffer, 101, ConfigFile);
- DelayTime = atoi(ConfigBuffer);
- if((DelayTime <= 0) || (DelayTime > 99)) Err = TRUE;
-
- fgets(ConfigBuffer, 101, ConfigFile);
- CheckTime = atoi(ConfigBuffer);
- if((CheckTime < 0) || (CheckTime > 99)) Err = TRUE;
-
- fgets(ConfigBuffer, 101, ConfigFile);
- CheckSumTry = atoi(ConfigBuffer);
- if((CheckSumTry < 0) || (CheckSumTry > 99)) Err = TRUE;
-
- fgets(ConfigBuffer, 101, ConfigFile);
- MSpeed = atoi(ConfigBuffer);
- if((MSpeed <= 0) || (MSpeed > MAXHARDSPEED)) Err = TRUE;
-
- fgets(ConfigBuffer, 101, ConfigFile);
- Method = atoi(ConfigBuffer);
- if((Method < 0) || (Method > 1)) Err = TRUE;
- fclose(ConfigFile);
- if(Err) Message(ERROR_ReadConfig);
- }
- else Err = TRUE;
- if(Err)
- {
- MSpeed = MAXHARDSPEED;
- Method = HARD;
- UnitNum = DEFUNIT;
- DelayTime = DEFDELAY;
- CheckTime = DEFCHECK;
- CheckSumTry = DEFCHECKSUM;
- strcpy(SerialName,"serial.device");
- }
- }
-
-
- VOID MoveHoriz(LONG Direction, LONG ByUser, LONG Cause)
- {
- int count;
- struct IntuiMessage *message;
- struct Gadget *Selected;
- long ActualNum;
-
- ActualNum = min(MAXFILENUM,FileNum[Cause]);
- do
- {
- if(Direction == LEFT)
- {
- if(HPos[Cause] >= (DirLen[Cause] - MAXDISPLAY)) return;
- HPos[Cause]++;
- }
- else
- {
- if(HPos[Cause] == 0) return;
- HPos[Cause]--;
- }
- Selected = (Cause == AM) ? AMSelect : PCSelect;
- RemoveGList(MainWin,Selected,MAXFILENUM);
- for(count = 0;count < ActualNum;count++)
- {
- strncpy(String[Cause][count],
- &(ItemAddr[Cause][count]->data[HPos[Cause]]), MAXDISPLAY);
- String[Cause][count][MAXDISPLAY] = NULL;
- }
- AddGList(MainWin,Selected,-1,MAXFILENUM,NULL);
- RefreshGList(Selected,MainWin,NULL,MAXFILENUM);
- if(ByUser)
- {
- if(Direction == LEFT)
- OldHPot[Cause] = OldHPot[Cause] + MAXBODY / (DirLen[Cause] - MAXDISPLAY);
- else
- OldHPot[Cause] = OldHPot[Cause] - MAXBODY / (DirLen[Cause] - MAXDISPLAY);
- NewModifyProp(&Gads[PCHPROP + Cause - 1],MainWin,NULL,PGHInfo[Cause].Flags,
- OldHPot[Cause],PGHInfo[Cause].VertPot,
- PGHInfo[Cause].HorizBody,PGHInfo[Cause].VertBody,1);
- }
- if(!ByUser) break;
- message = (struct IntuiMessage *)GetMsg(MainWin->UserPort);
- } while(message == NULL);
- if(ByUser) ReplyMsg((struct Message *) message);
- }
-
-
-
- VOID MoveVert(LONG Direction, LONG ByUser, LONG Cause)
- {
- int count;
- struct Gadget *Selected;
- struct IntuiMessage *message;
- long ActualNum;
-
- if(FileNum[Cause] <= MAXFILENUM) return;
- ActualNum = MAXFILENUM;
- do
- {
- if(Direction == UP)
- {
- if(ItemAddr[Cause][MAXFILENUM - 1]->next == NULL)
- {
- if(ByUser) ModifyP(-1,Cause);
- return;
- }
- }
- else
- {
- if(ItemAddr[Cause][0]->prev == NULL)
- {
- if(ByUser) ModifyP(0,Cause);
- return;
- }
- }
- Selected = (Cause == AM) ? AMSelect : PCSelect;
- RemoveGList(MainWin,Selected,MAXFILENUM);
- for(count = 0;count < ActualNum;count++)
- {
- if(Direction == UP)
- ItemAddr[Cause][count] = ItemAddr[Cause][count]->next;
- else
- ItemAddr[Cause][count] = ItemAddr[Cause][count]->prev;
-
- if(ItemAddr[Cause][count]->Selected)
- {
- if(ItemAddr[Cause][count]->type == FILETYPE)
- SelTexts[Cause][count].FrontPen = DPEN;
- else
- SelTexts[Cause][count].FrontPen = FPEN;
- Selected[count].Flags |= SELECTED;
- }
- else
- {
- if(ItemAddr[Cause][count]->type == FILETYPE)
- SelTexts[Cause][count].FrontPen = FPEN;
- else
- SelTexts[Cause][count].FrontPen = DPEN;
- Selected[count].Flags &= ~SELECTED;
- }
- strncpy(String[Cause][count],
- &(ItemAddr[Cause][count]->data[HPos[Cause]]), MAXDISPLAY);
- String[Cause][count][MAXDISPLAY] = NULL;
- }
- AddGList(MainWin,Selected,-1,MAXFILENUM,NULL);
- RefreshGList(Selected,MainWin,NULL,MAXFILENUM);
- if(ByUser)
- {
- if(Direction == UP)
- OldVPot[Cause] = OldVPot[Cause] + MAXBODY / (FileNum[Cause] - MAXFILENUM);
- else
- OldVPot[Cause] = OldVPot[Cause] - MAXBODY / (FileNum[Cause] - MAXFILENUM);
- NewModifyProp(&Gads[PCVPROP + Cause - 1],MainWin,NULL,PGVInfo[Cause].Flags,
- PGVInfo[Cause].HorizPot,OldVPot[Cause],
- PGVInfo[Cause].HorizBody,PGVInfo[Cause].VertBody,1);
- }
- if(!ByUser) break;
- message = (struct IntuiMessage *)GetMsg(MainWin->UserPort);
- } while(message == NULL);
- if(ByUser) ReplyMsg((struct Message *) message);
- }
-
-
- VOID PropHMoved(LONG Cause)
- {
- if(OldHPot[Cause] == PGHInfo[Cause].HorizPot) return;
- if(OldHPot[Cause] < PGHInfo[Cause].HorizPot)
- {
- while(OldHPot[Cause] < PGHInfo[Cause].HorizPot)
- {
- MoveHoriz(LEFT,0,Cause);
- if(OldHPot[Cause] > (MAXBODY - (MAXBODY / (DirLen[Cause] - MAXDISPLAY))))
- {
- OldHPot[Cause] = MAXBODY;
- break;
- }
- OldHPot[Cause] = OldHPot[Cause] + MAXBODY / (DirLen[Cause] - MAXDISPLAY);
- }
- }
- else
- {
- while(OldHPot[Cause] > PGHInfo[Cause].HorizPot)
- {
- MoveHoriz(RIGHT,0,Cause);
- if(OldHPot[Cause] < (MAXBODY / (DirLen[Cause] - MAXDISPLAY)))
- {
- OldHPot[Cause] = 0;
- break;
- }
- OldHPot[Cause] = OldHPot[Cause] - MAXBODY / (DirLen[Cause] - MAXDISPLAY);
- }
- }
- NewModifyProp(&Gads[PCHPROP + Cause - 1],MainWin,NULL,PGHInfo[Cause].Flags,
- OldHPot[Cause],PGHInfo[Cause].VertPot,
- PGHInfo[Cause].HorizBody,PGHInfo[Cause].VertBody,1);
- }
-
- VOID PropVMoved(LONG Cause)
- {
- if (FileNum[Cause] <= MAXFILENUM) return;
- if(OldVPot[Cause] < PGVInfo[Cause].VertPot)
- {
- while(OldVPot[Cause] < PGVInfo[Cause].VertPot)
- {
- MoveVert(UP,0,Cause);
- if(OldVPot[Cause] > (MAXBODY - (MAXBODY / (FileNum[Cause] - MAXFILENUM))))
- {
- OldVPot[Cause] = MAXBODY;
- break;
- }
- OldVPot[Cause] = OldVPot[Cause] + MAXBODY / (FileNum[Cause] - MAXFILENUM);
- }
- }
- else
- {
- while(OldVPot[Cause] > PGVInfo[Cause].VertPot)
- {
- MoveVert(DOWN,0,Cause);
- if(OldVPot[Cause] < (MAXBODY / (FileNum[Cause] - MAXFILENUM)))
- {
- OldVPot[Cause] = 0;
- break;
- }
- OldVPot[Cause] = OldVPot[Cause] - MAXBODY / (FileNum[Cause] - MAXFILENUM);
- }
- }
- NewModifyProp(&Gads[PCVPROP + Cause - 1],MainWin,NULL,PGVInfo[Cause].Flags,
- PGVInfo[Cause].HorizPot,OldVPot[Cause],
- PGVInfo[Cause].HorizBody,PGVInfo[Cause].VertBody,1);
- }
-
- VOID HandleMakeDir(VOID)
- {
- LONG Error,Done = FALSE;
- USHORT GadgetNum;
- struct Gadget *GadgetPtr;
- struct IntuiMessage *message;
-
- RemoveGList(MainWin,AMSelect,MAXFILENUM);
- RemoveGList(MainWin,PCSelect,MAXFILENUM);
- RemoveGList(MainWin,Gads,AMHPROP);
- AddGList(MainWin,&DirGad,-1,1,NULL);
- RefreshGList(&DirGad,MainWin,NULL,1);
- ActivateGadget(&DirGad,MainWin,NULL);
- Message(DIRNAME);
- do
- {
- WaitPort(MainWin->UserPort);
- message = (struct IntuiMessage *)GetMsg(MainWin->UserPort);
- GadgetPtr = (struct Gadget *)message->IAddress;
- GadgetNum = GadgetPtr->GadgetID;
- ReplyMsg((struct Message *) message);
- switch (GadgetNum)
- {
- case DIRSTRGAD: Done = TRUE; break;
- default: break;
- }
- } while(Done != TRUE);
- if(DirBuff[0] != NULL)
- {
- WaitPointer();
- if(Active == PC)
- {
- if((Error = RemoteMKDir(DirBuff))) Message(Error);
- else Message(SUCCESS);
- }
- else
- {
- if((Error = LocalMKDir(DirBuff))) Message(Error);
- else Message(SUCCESS);
- }
- NormalPointer();
- }
- else Message(CANCELED);
- Borders[15].FrontPen = 0;
- Borders[14].FrontPen = 0;
- Borders[13].FrontPen = 0;
- Borders[12].FrontPen = 0;
- DirBuff[0] = NULL;
- RefreshGList(&DirGad,MainWin,NULL,1);
- RemoveGList(MainWin,&DirGad,1);
- Borders[15].FrontPen = 2;
- Borders[14].FrontPen = 1;
- Borders[13].FrontPen = 1;
- Borders[12].FrontPen = 2;
- AddGList(MainWin,Gads,-1,AMHPROP,NULL);
- AddGList(MainWin,AMSelect,-1,MAXFILENUM,NULL);
- AddGList(MainWin,PCSelect,-1,MAXFILENUM,NULL);
- if(NumDone > 0)
- {
- RefreshGList(Gads,MainWin,NULL,AMHPROP);
- RefreshGList(AMSelect,MainWin,NULL,MAXFILENUM);
- RefreshGList(PCSelect,MainWin,NULL,MAXFILENUM);
- DrawBorder(MainWin->RPort,&Borders[23],0,0);
- if(!Error) HandleDir();
- }
- }
-
-
- VOID HandleCd(LONG Cause)
- {
- LONG Error;
-
- Activate(Cause);
- if(Cause == AM)
- {
- WaitPointer();
- Error = LocalCd(AMBuff);
- RefreshGList(&Gads[AMPATH - 1],MainWin,NULL,1);
- NormalPointer();
- }
- else
- {
- if(PCBuff[0] == NULL)
- strcpy(PCBuff,".");
- WaitPointer();
- Error = RemoteCd(PCBuff);
- strcpy(PCBuff,Packet.Data);
- RefreshGList(&Gads[PCPATH - 1],MainWin,NULL,1);
- NormalPointer();
- }
- if(!Error) HandleDir();
- else Message(Error);
- }
-
-
- VOID HandleParent(VOID)
- {
- if(Active == PC)
- {
- strcpy(PCBuff,"..");
- HandleCd(PC);
- }
- else
- {
- strcpy(AMBuff,"/");
- HandleCd(AM);
- }
- }
-
-
- VOID HandleDel(VOID)
- {
- LONG Error;
-
- WaitPointer();
- if(Active == AM)
- {
- if((Error = LocalDel())) Message(Error);
- else if(NumDone > 0) Message(SUCCESS);
- else Message(CANCELED);
- }
- else
- {
- if((Error = RemoteDel())) Message(Error);
- else if(NumDone > 0) Message(SUCCESS);
- else Message(CANCELED);
- }
- NormalPointer();
- if(NumDone > 0) HandleDir();
- }
-
-
- VOID HandleOverWrite(VOID)
- {
- if(OverWriteProtect == TRUE)
- {
- OverWriteProtect = FALSE;
- Gads[5].GadgetText = &Texts[10];
- }
- else
- {
- OverWriteProtect = TRUE;
- Gads[5].GadgetText = &Texts[9];
- }
- RefreshGList(&Gads[5],MainWin,NULL,1);
- }
-
- VOID HandleComm(VOID)
- {
- LONG Error,Prev;
-
- WaitPointer();
- if(Gads[0].GadgetText == &Texts[0]) /* connect */
- {
- CurrSpeed = MINSPEED - 1;
- if((Error = OpenSerial()))
- {
- Message(Error);
- CloseSerial();
- NormalPointer();
- return;
- }
- CurrSpeed = MSpeed - 1;
-
- if((Error = PutSpeedMethodDelay()))
- {
- Message(Error);
- CloseSerial();
- NormalPointer();
- return;
- }
-
- if((Error = SetSerial()))
- {
- Message(Error);
- CloseSerial();
- NormalPointer();
- return;
- }
- if(Active == PC) Gads[0].GadgetText = &Texts[2];
- else if(Active == AM) Gads[0].GadgetText = &Texts[1];
- RefreshGList(&Gads[0],MainWin,NULL,1);
- if(Mode == TEXT) Gads[4].GadgetText = &Texts[6];
- else Gads[4].GadgetText = &Texts[7];
- Gads[4].NextGadget = &Gads[5];
- RefreshGList(&Gads[4],MainWin,NULL,2);
- }
- else
- {
- if(Gads[0].GadgetText == &Texts[2]) /* receive */
- {
- if((Error = RemoteReceive())) Message(Error);
- if(NumDone > 0)
- {
- if(!Error) Message(SUCCESS);
- Prev = Active;
- Active = AM; HandleDir(); Active = Prev;
- }
- else Message(CANCELED);
- }
- else
- {
- if((Error = RemoteSend())) Message(Error);
- if(NumDone > 0)
- {
- if(!Error) Message(SUCCESS);
- Prev = Active;
- Active = PC; HandleDir(); Active = Prev;
- }
- else Message(CANCELED);
- }
- }
- NormalPointer();
- }
-
- VOID HandleQuit(VOID)
- {
- Message(InformOfQuit);
- WaitPointer();
- RemoteQuit();
- NormalPointer();
- }
-
-
- LONG CheckEsc(VOID)
- {
- struct IntuiMessage *message;
-
- message = (struct IntuiMessage *)GetMsg(MainWin->UserPort);
- while(message)
- {
- if(message->Class != RAWKEY)
- { ReplyMsg((struct Message *) message); return NO_ERROR; }
- if(message->Code == 0X45)
- { ReplyMsg((struct Message *) message); return ERROR_Break; }
- ReplyMsg((struct Message *) message);
- message = (struct IntuiMessage *)GetMsg(MainWin->UserPort);
- }
- return NO_ERROR;
- }
-
- extern struct MsgPort *TimerMP;
- extern struct timerequest *TimerIO;
-
-
- extern long Serial_OK;
-
- VOID main()
- {
- ULONG Sig;
- LONG Done = FALSE,Error;
- USHORT GadgetNum;
- struct Gadget *GadgetPtr;
- struct IntuiMessage *message;
- SHORT TimerSetup = FALSE;
-
- OpenAll();
- do
- {
- if(Serial_OK && (CheckTime > 0) && !OpenTimer())
- {
- TimerSetup = TRUE;
- TimerIO->tr_node.io_Command = TR_ADDREQUEST;
- TimerIO->tr_time.tv_secs = CheckTime;
- TimerIO->tr_time.tv_micro = 2;
- SendIO((struct IORequest *)TimerIO);
- Sig = Wait((1L << (MainWin->UserPort)->mp_SigBit) |
- (1L << TimerMP->mp_SigBit));
- AbortIO((struct IORequest *)TimerIO);
- WaitIO((struct IORequest *)TimerIO);
- CloseTimer();
- }
- else
- Sig = Wait(1L << (MainWin->UserPort)->mp_SigBit);
- if(Sig & (1L << (MainWin->UserPort)->mp_SigBit))
- {
- while(message = (struct IntuiMessage *)GetMsg(MainWin->UserPort))
- {
- if(message->Class == RAWKEY)
- {
- ReplyMsg((struct Message *) message);
- continue;
- }
- GadgetPtr = (struct Gadget *)message->IAddress;
- GadgetNum = GadgetPtr->GadgetID;
- NowSec = message->Seconds;
- NowMic = message->Micros;
- ReplyMsg((struct Message *) message);
- PrintFileName(NULL);
- ShowRemainder(0,0);
- ClrSer();
- switch (GadgetNum)
- {
- case EXIT: HandleQuit(); Done = TRUE; break;
- case COMM: HandleComm(); break;
- case PARENT: HandleParent(); break;
- case MKDIR: HandleMakeDir(); break;
- case CONFIG: Configure(); break;
- case DELETE: HandleDel(); break;
- case OVRWRITE: HandleOverWrite(); break;
-
- case PCUP: Activate(PC); MoveVert(DOWN,1,PC); break;
- case AMUP: Activate(AM); MoveVert(DOWN,1,AM); break;
- case PCDOWN: Activate(PC); MoveVert(UP,1,PC); break;
- case AMDOWN: Activate(AM); MoveVert(UP,1,AM); break;
- case PCVPROP: Activate(PC); PropVMoved(PC); break;
- case AMVPROP: Activate(AM); PropVMoved(AM); break;
- case PCLEFT: Activate(PC); MoveHoriz(RIGHT,1,PC); break;
- case AMLEFT: Activate(AM); MoveHoriz(RIGHT,1,AM); break;
- case PCRIGHT: Activate(PC); MoveHoriz(LEFT,1,PC); break;
- case AMRIGHT: Activate(AM); MoveHoriz(LEFT,1,AM); break;
- case PCHPROP: Activate(PC); PropHMoved(PC); break;
- case AMHPROP: Activate(AM); PropHMoved(AM); break;
-
- case AMPATH: HandleCd(AM); break;
- case PCPATH: HandleCd(PC); break;
-
- case AM1: EntrySelect(AM,0); break;
- case AM2: EntrySelect(AM,1); break;
- case AM3: EntrySelect(AM,2); break;
- case AM4: EntrySelect(AM,3); break;
- case AM5: EntrySelect(AM,4); break;
- case AM6: EntrySelect(AM,5); break;
- case AM7: EntrySelect(AM,6); break;
- case AM8: EntrySelect(AM,7); break;
- case AM9: EntrySelect(AM,8); break;
-
- case PC1: EntrySelect(PC,0); break;
- case PC2: EntrySelect(PC,1); break;
- case PC3: EntrySelect(PC,2); break;
- case PC4: EntrySelect(PC,3); break;
- case PC5: EntrySelect(PC,4); break;
- case PC6: EntrySelect(PC,5); break;
- case PC7: EntrySelect(PC,6); break;
- case PC8: EntrySelect(PC,7); break;
- case PC9: EntrySelect(PC,8); break;
- default: break;
- }
- } /* while Message */
- }
- else /* timer! */
- if((Error = CheckLink())) Message(Error);
- }while(!Done);
- if(First[AM]) FreeFInfo(AM);
- if(First[PC]) FreeFInfo(PC);
- CloseAll(0);
- }
-